<?php
	header('Access-Control-Allow-Origin:*');
    $username = $_GET['username'];
    $password = $_GET['password'];
    $con = new mysqli("127.0.0.1", "root", "", "accounting");
    $con->query("SET NAMES 'utf8'");
    //判断是否有该用户名
    $checkSQL = "select uid from user where nickname = '$username'";
    $res = $con->query($checkSQL);
    $line = mysqli_fetch_assoc($res);
    //获取记录行数
    if($line){
        echo "0";
    }
    else{
        $registSQL = "INSERT INTO `accounting`.`user` (`uid`, `nickname`, `password`, `mark`) VALUES (NULL, '$username', '$password', '')";
        $res = $con->query($registSQL);
        if($res){
            echo "1";
        }
        else{
            echo "2";
        }
    }
    exit;
?>